package com.comeon.calendar;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class TestCalendar {

	public static void main(String[] args) {
		System.out.println("please enter date:");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			try {
				Date d = df.parse(str);
				Calendar cal = new GregorianCalendar();
				cal.setTime(d);
				cal.set(Calendar.DATE, 1);
				int i = 1;
				System.out.println("日\t一\t二\t三\t四\t五\t六");
				int j = 1;
				while (cal.get(Calendar.DAY_OF_WEEK) - j > 0) {
					System.out.print('\t');
					j++;
				}
				while (i <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)) {
					System.out.print(i );
					if(d.getDate()==i)
						System.out.print("*");
					System.out.print("\t");
					if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY)
						System.out.println();
					i++;
					cal.add(Calendar.DATE, 1);
				}
                                                                                                                                                                                                                                                                                      			} catch (ParseException e) {
				e.printStackTrace();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
